public class Solution1422 {
    public int maxScore(String s) {
        int now=0,max;
        if (s.charAt(0)=='0'){
            now=1;
        }
        for (int i=1;i<s.length();i++){
            if (s.charAt(i)=='1'){
                now++;
            }
        }
        max=now;
        for (int i=1;i<s.length()-1;i++){
            if (s.charAt(i)=='1'){
                now--;
            }else {
                now++;
            }
            max=Math.max(max,now);
        }
        return max;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1422().maxScore("011101"));
    }
}
